﻿<%@ WebHandler Language="C#" Class="ListOrder" %>

using System;
using System.Web;

public class ListOrder : AdminHandler
{
    
    public override void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        if (IsAuthenticate(context))
        {
            try
            {
                int pageIndex = 1, pageMax = 10, userid = 0;
                int isView = -1, isCancel = -1, isFinish = -1;
                DateTime fromDate = DateTime.Now, toDate = DateTime.Now;
                
                if (context.Request.QueryString["pi"] != null)
                    pageIndex = int.Parse(context.Request.QueryString["pi"].ToString());
                if (context.Request.QueryString["pm"] != null)
                    pageMax = int.Parse(context.Request.QueryString["pm"].ToString());
                if (context.Request.QueryString["ui"] != null)
                    userid = int.Parse(context.Request.QueryString["ui"].ToString());
                if (context.Request.QueryString["iv"] != null)
                    isView = int.Parse(context.Request.QueryString["iv"].ToString());
                if (context.Request.QueryString["ic"] != null)
                    isCancel = int.Parse(context.Request.QueryString["ic"].ToString());
                if (context.Request.QueryString["if"] != null)
                    isFinish = int.Parse(context.Request.QueryString["if"].ToString());
                if (context.Request.QueryString["fd"] != null)
                    fromDate = DateTime.Parse(context.Request.QueryString["fd"].ToString());
                if (context.Request.QueryString["td"] != null)
                    toDate = DateTime.Parse(context.Request.QueryString["td"].ToString());
                ///Lỗi procedure
                if (pageIndex == 0)
                    pageIndex = 1;

                string result = "";
                Order obj = new Order();
                System.Collections.Generic.IList<Order> list = obj.List(pageIndex, pageMax, userid, isView, isFinish, isCancel, fromDate, toDate);
                result = obj.ToJsonList<Order>(list);
                context.Response.Write(result);
            }
            catch (Exception ex)
            {
                PMSA.Framework.Log.CLogManager.Write("ListOrder.ashx", ex.ToString(), "ADMIN");
                context.Response.Write("FAIL");
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}